Skip to content

Update to JET.jl v0.11#248

Merged
JoshuaLampert merged 5 commits intomainfrom
JET-v0-11
Nov 4, 2025
Merged

Update to JET.jl v0.11#248
JoshuaLampert merged 5 commits intomainfrom
JET-v0-11

Conversation

@JoshuaLampert
Copy link
Copy Markdown
Member

See #246 (comment).
Trying this locally gave a lot of errors from JET.jl, but they looked real. So let's see what CI says.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 3, 2025

Benchmark Results (Julia v1.10)

Time benchmarks
main 9168ccf... main / 9168ccf...
bbm_1d/bbm_1d_basic.jl - rhs!: 13.8 ± 0.26 μs 13.8 ± 0.3 μs 1 ± 0.029
bbm_1d/bbm_1d_fourier.jl - rhs!: 0.216 ± 0.0096 ms 0.529 ± 0.0096 ms 0.409 ± 0.02
bbm_bbm_1d/bbm_bbm_1d_basic_reflecting.jl - rhs!: 0.0805 ± 0.0004 ms 0.0812 ± 0.0004 ms 0.992 ± 0.007
bbm_bbm_1d/bbm_bbm_1d_dg.jl - rhs!: 0.0346 ± 0.0016 ms 0.0342 ± 0.00043 ms 1.01 ± 0.05
bbm_bbm_1d/bbm_bbm_1d_relaxation.jl - rhs!: 27.5 ± 2.5 μs 27.6 ± 0.88 μs 0.998 ± 0.097
bbm_bbm_1d/bbm_bbm_1d_upwind_relaxation.jl - rhs!: 0.0487 ± 0.00095 ms 0.0484 ± 0.0005 ms 1.01 ± 0.022
hyperbolic_serre_green_naghdi_1d/hyperbolic_serre_green_naghdi_dingemans.jl - rhs!: 4.25 ± 0.031 μs 4.25 ± 0.04 μs 1 ± 0.012
kdv_1d/kdv_1d_basic.jl - rhs!: 1.5 ± 0.02 μs 1.47 ± 0.01 μs 1.02 ± 0.015
kdv_1d/kdv_1d_implicit.jl - rhs!: 1.41 ± 0.01 μs 1.46 ± 0.01 μs 0.966 ± 0.0095
serre_green_naghdi_1d/serre_green_naghdi_well_balanced.jl - rhs!: 0.197 ± 0.0084 ms 0.198 ± 0.0071 ms 0.993 ± 0.055
svaerd_kalisch_1d/svaerd_kalisch_1d_dingemans_relaxation.jl - rhs!: 0.146 ± 0.0038 ms 0.147 ± 0.0043 ms 0.993 ± 0.039
time_to_load 1.96 ± 0.015 s 1.95 ± 0.02 s 1 ± 0.013
Memory benchmarks
main 9168ccf... main / 9168ccf...
bbm_1d/bbm_1d_basic.jl - rhs!: 1 allocs: 4.12 kB 1 allocs: 4.12 kB 1
bbm_1d/bbm_1d_fourier.jl - rhs!: 1 allocs: 4.12 kB 1 allocs: 4.12 kB 1
bbm_bbm_1d/bbm_bbm_1d_basic_reflecting.jl - rhs!: 5 allocs: 1.17 kB 5 allocs: 1.17 kB 1
bbm_bbm_1d/bbm_bbm_1d_dg.jl - rhs!: 10 allocs: 8.62 kB 10 allocs: 8.62 kB 1
bbm_bbm_1d/bbm_bbm_1d_relaxation.jl - rhs!: 2 allocs: 8.25 kB 2 allocs: 8.25 kB 1
bbm_bbm_1d/bbm_bbm_1d_upwind_relaxation.jl - rhs!: 2 allocs: 8.25 kB 2 allocs: 8.25 kB 1
hyperbolic_serre_green_naghdi_1d/hyperbolic_serre_green_naghdi_dingemans.jl - rhs!: 0 allocs: 0 B 0 allocs: 0 B
kdv_1d/kdv_1d_basic.jl - rhs!: 0 allocs: 0 B 0 allocs: 0 B
kdv_1d/kdv_1d_implicit.jl - rhs!: 0 allocs: 0 B 0 allocs: 0 B
serre_green_naghdi_1d/serre_green_naghdi_well_balanced.jl - rhs!: 0.075 k allocs: 0.66 MB 0.075 k allocs: 0.66 MB 1
svaerd_kalisch_1d/svaerd_kalisch_1d_dingemans_relaxation.jl - rhs!: 0.042 k allocs: 0.315 MB 0.042 k allocs: 0.315 MB 1
time_to_load 0.153 k allocs: 14.5 kB 0.153 k allocs: 14.5 kB 1

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/callbacks_step/relaxation.jl 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@JoshuaLampert
Copy link
Copy Markdown
Member Author

JoshuaLampert commented Nov 3, 2025

I fixed all the issues JET.jl v0.11 found apart from three:

  • local variable `accumulated_data` may be undefined: accumulated_data::TimerOutputs.TimeData: This probably comes from TrixiBase.jl. I guess it's https://github.com/trixi-framework/TrixiBase.jl/blob/b65bea70512e393bc82bd64a09765ad0c74bc586/src/trixi_timeit.jl#L66. I'll see if I can fix it there. Edit: Should be fixed by Fix issues found by JET.jl trixi-framework/TrixiBase.jl#57.
  • local variable `psi` may be undefined: psi::Any: That's a bit tricky. I see why JET.jl complains about this part. But it's not so easy to fix it nicely because we cannot merge the if statements easily and it's also not so nice to always unpack psi again in each if statement. Any idea, @ranocha?
  • no matching method found `is_key_supported(::Symbol)`: (RecipesBase).is_key_supported::typeof(RecipesBase.is_key_supported)(:plot_initial): This comes from RecipesBase.jl and is probably why we needed the workaround before (?). I'll need to check if we can ignore these somehow with JET.jl v0.11 (ignored_modules = (RecipesBase,) doesn't help). Edit: I fixed that by importing Plots.jl before testing, which makes is_key_supported available.

@ranocha
Copy link
Copy Markdown
Member

ranocha commented Nov 3, 2025

That's a bit tricky. I see why JET.jl complains about this part. But it's not so easy to fix it nicely because we cannot merge the if statements easily and it's also not so nice to always unpack psi again in each if statement.

You can report this as a sub-optimal result of JET.jl. From looking at the code, I do not see an obvious way how psi could not be defined there.

To fix this right now, the only option I see is to unpack psi every time from the cache.

@JoshuaLampert
Copy link
Copy Markdown
Member Author

JoshuaLampert commented Nov 3, 2025

That's a bit tricky. I see why JET.jl complains about this part. But it's not so easy to fix it nicely because we cannot merge the if statements easily and it's also not so nice to always unpack psi again in each if statement.

You can report this as a sub-optimal result of JET.jl. From looking at the code, I do not see an obvious way how psi could not be defined there.

Yes, JET.jl is not smart enough to realize that the first first if equations.bathymetry_type isa BathymetryVariable condition will always be true and therefore psi will be defined when the other if equations.bathymetry_type isa BathymetryVariable conditions are true. That's also basically the same issue with the first problem from @trixi_timeit in TrixiBase.jl.
I now always unpack psi from the cache.

@ranocha
Copy link
Copy Markdown
Member

ranocha commented Nov 4, 2025

Did you file an issue in their repo? They should know about false positives like this.

@JoshuaLampert
Copy link
Copy Markdown
Member Author

Did you file an issue in their repo? They should know about false positives like this.

No because this is the same as aviatesk/JET.jl#749. So the compiler cannot infer that in the second branch the variable is defined and we need to resort to workarounds. I am not a big fan of adding assertions in the branches as was also suggested in the issue above. So I think the only way to make JET.jl pass is using the workarounds we already found (unpacking psi in every branch and code duplication in TrixiBase.jl).

Copy link
Copy Markdown
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks good to me so far. We need to finalize your PR to TrixiBase.jl and release a new version.

Copy link
Copy Markdown
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to trigger CI again when JuliaRegistries/General#141816 is merged and merge this PR if tests pass. Thanks!

@JoshuaLampert JoshuaLampert enabled auto-merge (squash) November 4, 2025 14:56
@JoshuaLampert JoshuaLampert merged commit f5000ad into main Nov 4, 2025
13 of 14 checks passed
@JoshuaLampert JoshuaLampert deleted the JET-v0-11 branch November 4, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants